 Script
#!/bin/bash

# 构建并推送Docker镜像到容器实例
INSTANCE_URL=crpi-1oac5tnrcscsinwz.cn-hangzhou.personal.cr.aliyuncs.com/ahgeng


# 运行Maven清理和打包命令
echo "开始执行 Maven 清理与打包..."
mvn clean package

# 检查Maven命令是否成功
if [ $? -eq 0 ]; then
    echo "Maven 打包成功。"
else
    echo "Maven 打包失败，终止后续操作。"
    exit 1
fi

# 构建Docker镜像
echo "Building Docker image..."
docker build -t tyrzpt-api:1.1.0 .

# 标记Docker镜像
echo "Tagging Docker image..."
docker tag tyrzpt-api:1.1.0 $INSTANCE_URL/tyrzpt-api:1.1.0

# 推送Docker镜像
echo "Pushing Docker image..."
docker push $INSTANCE_URL/tyrzpt-api:1.1.0

# 完成Docker镜像的构建和推送
echo "Docker image build and push completed."
